/**
 * 
 */
package com.kandinfo.survey.common.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kandinfo.base.common.dto.ResultDto;
import com.kandinfo.survey.common.dto.useranswer.UserAnswerRequestDto;
import com.kandinfo.survey.common.service.UserAnswerService;

/**
 * 用户答题Controller, created on 12/7/2016
 * 
 * @author Patrick-chenzp
 */
@Controller
@RequestMapping("/useranswer")
public class UserAnswerController {

    @Autowired
    UserAnswerService userAnswerService;

    /**
     * 用户做题试卷关系保存，用户开始做试卷保存一次（----参数判断, 前台判断----）
     */
    @RequestMapping(value = "/saverela", method = RequestMethod.POST)
    @ResponseBody
    public void saveRela(@RequestParam UserAnswerRequestDto requestDto) {
        userAnswerService.saveRela(requestDto);
    }
    
    /**
     * 用户做题试卷关系逻辑删除（----参数判断, 前台判断----）
     */
    @RequestMapping(value = "/deleterela", method = RequestMethod.POST)
    @ResponseBody
    public ResultDto deleteRela(@RequestParam UserAnswerRequestDto requestDto) {
        return userAnswerService.deleteRela(requestDto);
    }

    /**
     * 保存用户答题数据, 无需返回结果（----参数判断, 前台判断----）
     */
    @RequestMapping(value = "/savedata", method = RequestMethod.POST)
    @ResponseBody
    public void saveData(@RequestParam UserAnswerRequestDto requestDto) {
        userAnswerService.saveData(requestDto);
    }

}
